﻿using Core.Infrastructure;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.WebPages;
using System.Linq;
using Web.Framework.Themes;

namespace Web
{
    public class Bootstrapper
    {
        public static void Bootstrap()
        {
            // we use our own mobile devices support (".Mobile" is reserved). that's why we disable it.
            var mobileDisplayMode = DisplayModeProvider.Instance.Modes
                                                       .FirstOrDefault(x => x.DisplayModeId == DisplayModeProvider.MobileDisplayModeId);
            if (mobileDisplayMode != null)
                DisplayModeProvider.Instance.Modes.Remove(mobileDisplayMode);

            // initialize engine context
            EngineContext.Initialize(false);

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // We do no register System.Web.Routing.RouteTable
            // RouteConfig.RegisterRoutes(RouteTable.Routes); 
            // use custome router
            RouteConfigurator.RegisterRoutes(RouteTable.Routes);

            //if (databaseInstalled)
            //{
                // remove all view engines
                ViewEngines.Engines.Clear();
                // except the themeable razor view engine we use
                ViewEngines.Engines.Add(new ThemeableRazorViewEngine());
            //}

            //ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(IoC.Container));
            //WindsorConfigurator.Configure();
            //AwesomeConfigurator.Configure();

            //Globals.PicturesPath = HttpContext.Current.Server.MapPath("~/pictures");
            //new Worker().Start();
        }
    }
}